#!/usr/bin/env python

# To run the tests
#     TestPrimes.py

# To document the tests
#     pydoc -w Primes

import main
import unittest

# ----------
# TestReader
# ----------

class TestReader (object) :
    def __init__ (self, s) :
        self.s = s

    def read (self) :
        return self.s

# ----------
# TestWriter
# ----------

class TestWriter (object) :
    def str (self) :
        return self.s

    def write (self, *a) :
        self.s = str(a[0])
        for w in a[1:] :
            self.s += ' '
            self.s += str(w)
        self.s += '\n'

# ----------
# TestPrimes
# ----------

class TestPrimes (unittest.TestCase) :
    def test_eval1(self):
      test = 10
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
    def test_eval2(self):
      test = 24
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
    def test_eval3(self):
      test = 36
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
      
    def test_eval4(self):
      test = 46
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
    def test_eval5(self):
      test = 10000000
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
    def test_eval6(self):
      test = 6790
      main.num = test
      main.my_eval()
      self.assert_(main.a + main.b + main.c + main.d == test)
      
            
# --------
# is_prime
# --------
class TestIsPrime (unittest.TestCase) :
    def test_is_prime1(self):
      test = main.is_prime(10)        
      self.assert_(test == False)
      
    def test_is_prime2(self):
      test = main.is_prime(9)        
      self.assert_(test == False)

    def test_is_prime3(self):
      test = main.is_prime(1)        
      self.assert_(test == False)

    def test_is_prime4(self):
      test = main.is_prime(0)        
      self.assert_(test == False)

    def test_is_prime5(self):
      test = main.is_prime(-1)        
      self.assert_(test == False)
      
      
if __name__ == "__main__" :
    unittest.main()

